import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

//10个Item
class TopNavigator extends StatelessWidget {
  final List navgatorList;

  Widget _grideViewItemUI(BuildContext context, item) {
    return InkWell(
      onTap: () {
        Scaffold.of(context).showSnackBar(SnackBar(
          content: Text("点击了${item["mallCategoryName"]}"),
          duration: Duration(seconds: 1),
        ));
      },
      child: Column(
        children: <Widget>[
          Image.network(item["image"], width: ScreenUtil().setWidth(95)),
          Text(item["mallCategoryName"]),
        ],
      ),
    );
  }

  TopNavigator({
    this.navgatorList,
  });

  @override
  Widget build(BuildContext context) {
    if (navgatorList.length > 10) {
      this.navgatorList.removeRange(10, navgatorList.length);
    }
    return Container(
      padding: EdgeInsets.all(3),
      height: ScreenUtil().setHeight(320),
      child: GridView.count(
        physics: NeverScrollableScrollPhysics(), //禁用滑动,解决冲突
        crossAxisCount: 5,
        padding: EdgeInsets.all(5),
        children: navgatorList.map((item) {
          return _grideViewItemUI(context, item);
        }).toList(),
      ),
    );
  }
}
